using System;

using Slaks.Descriptions;

namespace Slaks.Filters
{
    [ModuleDescriptionAttribute("English summary term filter", "Slava Kisilevich/Marina Litvak")]
    public class EnglishTermFilter : Slaks.Filters.AFilter
    {
        protected static int EnglishCapitalLetterBegin = 0x41;
        protected static int EnglishCapitalLetterEnd = 0x5a;

        protected static int EnglishSmallLetterBegin = 0x61;
        protected static int EnglishSmallLetterEnd = 0x7a;

        protected static int DigitZero = 0x30;
        protected static int DigitNine = 0x39;

        protected static int HypherLine = 0x2d;

        public EnglishTermFilter() { }

        /// <summary>
        /// All characters that are not english letters neither digitals are considered white space.
        /// </summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        
        public override bool IsWhiteSpace(char ch)
        {
            if ((ch >= DigitZero && ch <= DigitNine) ||
                (ch >= EnglishCapitalLetterBegin && ch <= EnglishCapitalLetterEnd) ||
                (ch >= EnglishSmallLetterBegin && ch <= EnglishSmallLetterEnd) ||
                ch == HypherLine)
                return false;
            return true;
        }
        /// <summary>
        /// Normalizes the character by lowering
        /// </summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        public override char Normalize(char ch)
        {
            return char.ToLower(ch);
        }

        public override bool IsEndOfSentencePunctuationMark(char ch)
        {
            if (ch == GeneralEndOfSentencePunctuationMarkDot ||
                ch == GeneralEndOfSentencePunctuationMarkExclamation ||
                ch == GeneralEndOfSentencePunctuationMarkQuestion) return true;

            return false;
        }

        public override bool IsMiddleSentencePunctuationMark(char ch)
        {
            if (ch == GeneralMiddleOfSentencePunctuationMarkComma) return true;
            return false;
        }

        public override string ToString()
        {
            return "english filter";
        }

    }
}
